<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>卡券领取</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="author" content="runoob">
    <link rel="stylesheet" type="text/css" href="__STATIC_URL__/static/mobile/css/index.css"/>
    <link rel="stylesheet" href="__STATIC_URL__/static/mobile/css/weui.css" />
    <script src="__STATIC_URL__/static/layer.mobile/layer_mobile/layer.js"></script>
</head>
<style>
    h3{
        color: #FFFFFF;
    }
    .container .page__bd li {
        margin: 10px 0;
        background-color: #fff;
        overflow: hidden;
        border-radius: 2px;
        cursor: pointer;
    }
    .page__bd_spacing {
        padding: 0 15px;
    }
    .page__bd {
        padding: 20px;
        -webkit-box-align: center;
        -webkit-align-items: center;
        align-items: center;
        font-size:13px;
        -webkit-transition: .3s;
        transition: .3s;
        text-align: left;
    }
    .page__bd  .weui-flex__item{
        font-size:21px
    }
    .weui-flex__item img{
    border-radius:50%;
        width: 38px;
        padding-left: 16%;
    }
    .weui-cell:before {

        border-top: 1px solid #fff;

    }
    footer {
        position: fixed;
        height: 34px;
        left: 0;
        right: 0;
        bottom: 95px;
    }
</style>
<body style="">

<!------------------导航-------------------------->
<section>

    <!--------------------------主要内容区域------------------------------------->
    <div class="container" id="container" style="margin: 0;text-align: center;    margin-bottom: 200px;">

        <div class="page__bd page__bd_spacing" style="margin-top: 10%">
            <ul>
                {volist name="usercard" id="vo"}
                <li data-cardid="{$vo['card_id']}" class="weui-cell">
                    <div class="weui-flex js_category weui-cell__hd" style="width:30%">
                        <div class="weui-flex__item">
                            <img src="{:cardgetinfo($vo['card_id'],1,0)}" alt="">
                        </div>
                    </div>
                    <div class=" js_category weui-cell__bd" style="width:70%">

                           <p style="width:100%;">{:cardgetinfo($vo['card_id'],1,2)}</p>
                           <p class="weui-flex__item" style="width:100%;">{:getcardtitle($vo['card_id'])}*{$vo['get_num']}张</p>

                    </div>
                </li>
                {/volist}
            </ul>


            <!--<div class="weui-loadmore">-->
                <!--<i class="weui-loading" style="width: 60px;height: 60px;"></i>-->
            <!--</div>-->
            <!--<div class="weui-msg__text-area">-->
                <!--<h2 class="weui-msg__title">正在加载</h2>-->
                <!--<p class="weui-msg__desc"></p>-->
            <!--</div>-->
        </div>

    </div>
    <div id="toast" style="display: none;">
        <div class="weui-mask"></div>
        <div class="weui-toast">
            <i class="weui-loading weui-icon_toast"></i>
            <p class="weui-toast__content">数据加载中</p>
        </div>
    </div>
    <footer>
        <div class="button-sp-area" style="margin:0 50px 50px 50px"; >
            <a href="javascript:;" class="weui-btn weui-btn_primary" id="weui-btn_primary" onclick="primary();">
                领取
            </a>
        </div>
    </footer>
</section>
<script src="__STATIC_URL__/static/jquery/3.2.1/jquery.min.js"></script>
<script src="https://res.wx.qq.com/open/libs/weuijs/1.0.0/weui.min.js"></script>
<script src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script src="__STATIC_URL__/static/layer/layer.js" type="text/javascript" charset="utf-8"></script>
<script>
        function primary(){
            var $toast = $('#toast');
            $("#weui-btn_primary").removeAttr("onclick");

                $toast.attr("style","display:block");

            $.post({
                url: "{:url('cardgettest/getcardslistnu')}",
                data: {
                    mid:{$arr['mid']},
                    rec_id:{$arr['rec_id']},
                    url: window.location.href
                },
                success: function (data) {
                    console.log(data);
//                    return;
                    if (data.code == '0') {

                        wx.config({
                            debug: false,
                            appId: data.data.jssdk.appId,
                            timestamp: data.data.jssdk.timestamp,
                            nonceStr: data.data.jssdk.nonceStr,
                            signature: data.data.jssdk.signature,
                            jsApiList: [
                                'addCard'
                            ]
                        });
                        wx.ready(function () {
                            wx.addCard({
                                cardList: data.data.card,
                                success: function (res) {
                                    $.ajax({
                                        url: "{:url('cardget/logtest')}",
                                        data: {
                                            info: res,
                                        },
                                        dataType: "JSON",           //类型
                                        type: "post",                 //方式
                                        success: function (res) {


                                        }


                                    });
//                    console.log('已添加卡券：' + JSON.stringify(res.cardList));
                                    window.location.replace("{:url('cardget/cardgetsuccess')}")

                                },
                            });
                        });

                }else{
                        layer.alert(data.message);
                }
                 }
            })
        }


</script>
<script>
//     $(function () {
//
//         wx.config({
//             debug: false,
//             appId: "",
//             timestamp: "",
//             nonceStr: "",
//             signature: "",
//             jsApiList: [
//                 'addCard'
//
//             ]
//         });
//         wx.ready(function () {
//             wx.addCard({
//                 cardList:,
//                 success: function (res) {
// //                    console.log('已添加卡券：' + JSON.stringify(res.cardList));
//                     window.location.replace("{:url('cardget/cardgetsuccess')}")
//                 },
// //                 error:function (res) {
// // //                    alert('已添加卡券：' + JSON.stringify(res.cardList));
// //                     alert('领取成功');
// //                 }
//             });
//
//         })
//     })

</script>
</body>
</html>
